import random
class Food:
    x = 0 # 食物所在的x坐标
    y = 0 # 食物所在的y坐标
    grid_size = 0

    def __init__(self, x, y, grid_size) -> None:
        self.x = x
        self.y = y
        self.grid_size = grid_size
    
    @staticmethod
    def random_food(screen_x, screen_y, grid_size, filter_grids):
        randposlist = [(x, y) 
        for x in range(0, int(screen_x/grid_size) + 1) 
        for y in range(0, int(screen_y/grid_size) + 1) 
        if (x, y) not in filter_grids]
        (choice_x, choice_y) = random.choice(randposlist)
        return Food(choice_x, choice_y, grid_size)

    def get_draw_grid(self):
        return self.x * self.grid_size, self.y * self.grid_size

    def get_grid(self):
        return (self.x, self.y)
        

